<template>
  <div :style="'background-color:' + color" class="notify" v-if="msg">
    {{ msg }}-{{ color }}
  </div>
</template>
<style scoped>
.notify {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 44px;
  line-height: 44px;
  text-align: center;
  color: #fff;
  background-color: #0092d1;
}
</style>
<script>
export default {
  data() {
    // 要提示的文本
    return { msg: "", color: "#0092d1" };
  },
  methods: {
    // 显示提示
    show(str, delay = 2000, color = "#0092d1") {
      this.msg = str;
      this.color = color;
      this.ind = setTimeout(() => {
        this.hide();
      }, delay);
    },
    // 隐藏提示
    hide() {
      this.msg = "";
    },
  },
};
</script>
